public class AddTwoNumberInNode {
    public ListNode addTwoNumbers(ListNode l1, ListNode l2) {
        int left = 0;
        ListNode dump = new ListNode(-1);
        ListNode cur = dump;
        while (l1 != null || l2 != null || left != 0) {
            int val1 = l1 == null ? 0 : l1.val;
            int val2 = l2 == null ? 0 : l2.val;
            int sum = (val1 + val2 + left);
            int res = sum % 10;
            cur.next = new ListNode(res);
            left = sum / 10;
            if (l1 != null) {
                l1 = l1.next;
            }
            if (l2 != null) {
                l2 = l2.next;
            }
            cur = cur.next;
        }

        return dump.next;
    }
}
